home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / turbo-tcp-20b4-cpp.hqx / TurboTCP / TurboTCP source / CTCPDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-03  |  3.6 KB  |  144 lines

  1. /*
  2. ** CTCPDriver.h
  3. **
  4. **    TurboTCP support library
  5. **    TCP driver interface class
  6. **
  7. **    Copyright © 1993-94, FrostByte Design / Eric Scouten
  8. */
  9.  
  10.  
  11. #pragma once
  12.  
  13. #include "TCL.h"
  14.  
  15. #include <MacTCPCommonTypes.h>
  16. #include <OSUtils.h>
  17.  
  18. class CTCPAsyncCall;
  19. class CTCPDriver;
  20. class CTCPStream;
  21. class CTCPResolverCall;
  22.  
  23. #ifndef TCL_NO_TEMPLATES
  24.     class CTCPStreamList;
  25.     class CTCPResolverCallList;
  26. #else
  27.     class CPtrArray_CTCPStream;
  28.     class CPtrArray_CTCPResolverCall;
  29.     #define CTCPStreamList CPtrArray_CTCPStream
  30.     #define CTCPResolverCallList CPtrArray_CTCPResolverCall
  31. #endif
  32.  
  33.  
  34. #define maxResolverCalls        8            // maximum DNR calls open simultaneously
  35.  
  36.  
  37. // asynchronous queue entries
  38.  
  39. enum asyncQueueType {
  40.     asyncCall = 1,
  41.     resolverCall,
  42.     notifyStream,
  43.     disposeStream
  44. };
  45.  
  46. #if defined(powerc) || defined (__powerc)
  47. #pragma options align=mac68k
  48. #endif
  49.  
  50. struct TurboTCPQElem {
  51.     struct QElem*        qLink;                // next item in queue
  52.     short            qType;                // entry type — see asyncQueueType above
  53.     void*            qSelfLink;                // link to whatever object we had
  54.     TurboTCPQElem(void* itsSelfLink) : qSelfLink(itsSelfLink) {}
  55.                                         // special constructor
  56. };
  57.  
  58. #if defined(powerc) || defined(__powerc)
  59. #pragma options align=reset
  60. #endif
  61.  
  62. typedef enum asyncQueueType asyncQueueType;
  63. typedef struct TurboTCPQElem TurboTCPQElem;
  64. typedef TurboTCPQElem* TurboTCPQElemPtr;
  65.  
  66.  
  67. /*______________________________________________________________________
  68. **
  69. ** CTCPDriver
  70. **
  71. **    This object performs all of the housekeeping associated with the MacTCP driver.
  72. **    It keeps track of all currently open streams and handles the delayed-processing of
  73. **    MacTCP completions and notifications. It is also responsible for seeing that MacTCP is
  74. **    in a stable state (i.e. no streams left open, DNR closed) before the application quits.
  75. **
  76. **    NOTE: This class is intended for the internal use of other TurboTCP classes only.
  77. **    Accordingly, all of its methods are declared private and friend class declarations are
  78. **    used to make its members available as appropriate. No user class should have a reason
  79. **    to use this object, nor should this object be subclassed. 
  80. **
  81. **    In a future version of TurboTCP, this class will be made an abstract class to support
  82. **    MacTCP and Open Transport versions of the driver object.
  83. **
  84. */
  85.  
  86.  
  87. class CTCPDriver {
  88.  
  89. private:
  90.     friend class CTCPAsyncCall;
  91.     friend class CTCPStream;
  92.     friend class CTCPResolverCall;
  93.     friend class UTurboTCP;
  94.  
  95.  
  96.     // TCP driver availability information
  97.  
  98.     static CTCPDriver*        gTCPDriver;                // global reference to this object
  99.     Boolean                hasMacTCP;                // is there a MacTCP driver available?
  100.     Boolean                hasResolver;                // is the DNR code segment available?
  101.     short                myTCPRefNum;                // MacTCP driver’s ioRefNum
  102.     ip_addr                myIPAddress;                // our IP address
  103.  
  104.     // list of active streams/resolvers
  105.  
  106.     CTCPStreamList*        activeStreamList;            // list of active TCP streams
  107.     CTCPResolverCallList*    activeResolverList;            // list of active DNR calls
  108.     
  109.     // interrupt-process queue
  110.  
  111.     QHdr                    asyncQueue;                // interrupt-event queue
  112.  
  113.  
  114.     // constructor/destructor
  115.  
  116.                         CTCPDriver();
  117.     virtual                ~CTCPDriver() {}            // don’t use this -- use Dispose() instead
  118.     void                    Dispose();
  119.  
  120.  
  121.     // event handling
  122.     
  123.     Boolean                ProcessOneNetEvent();
  124.  
  125.  
  126.     // TCP verification routines
  127.     
  128.     ip_addr                GetIPAddr();
  129.     Boolean                CheckTCPDriver();
  130.     Boolean                CheckResolver();
  131.     short                GetTCPRefNum();
  132.     void                    FetchIPAddr();
  133.  
  134.  
  135.     // tracking active streams/resolvers
  136.  
  137.     void                    RegisterActiveStream(CTCPStream* theStream);
  138.     void                    RegisterActiveResolver(CTCPResolverCall* theResolver);
  139.     void                    RemoveActiveStream(CTCPStream* theStream);
  140.     void                    RemoveActiveResolver(CTCPResolverCall* theResolver);
  141.     Boolean                CheckResolverLimit();
  142.     
  143. };
  144.